#define _GNU_SOURCE
#include<stdio.h>
#include<stdlib.h>
#include<pthread.h>
#include<unistd.h>

//first thread
void * first_thread(void *arg){
    printf("first thread......id:%d\n",gettid());
}

//second thread
void * second_thread(void *arg){
    printf("second thread......id:%d\n",gettid());
}

int main(int argc, char const *argv[])
{
    printf("处于主进程的 主线程的执行开始  id:%d\n",gettid());

    //创建两个分线程
    pthread_t tid1,tid2;
    pthread_create(&tid1,NULL,first_thread,NULL);
    pthread_create(&tid2,NULL,second_thread,NULL);

    //等待两个分线程执行结束
    pthread_join(tid1,NULL);
    pthread_join(tid2,NULL);

    printf("主线程的执行结束\n");
    return 0;
}

